#!/usr/bin/perl

print "Gb tool analyser. \n";

open INPUT, "<", "log.txt" or die $!;
#open $fin, "<", "log.txt" or die $!;
open $fout, ">", "output.txt";

#chomp(@array);
#choml(@array);
$line_number = 0;
$line = 1;
@array;

#while ($line_number = <$fin> )
#{
#	print $line_number;
#	$line++;
#	push(@array, $line_number);
#}

@array = <INPUT>;

close ($fin);

#	print "Array: \n";
#	print $fout @array;
#	$length_file = scalar (@array);
#	print $length_file, "\n";
#	print scalar(@array), "\n";
#	$abc = @array;
#	print $abc, "\n";

#	print "\n", $line, "\n";
#	print "start of file: \n";
#	print @array[0];
#	print @array[1];
#	print @array[2];
#	print @array[3];
#	print @array[4];
#	print @array[5];
#	print "====================================== \n";
#	print "begin 6 lines of file: \n";

for ($i = 0; $i < scalar(@array); $i++)	
{
#	print "normal: \n";
#	print @array[$i];
	chomp (@array[$i]);
	if (@array[$i] =~ /03E8/ )
	{
#		print length(@array[$i]), "\n";
#		print @array[$i], length(@array[$i]), "\n";		
		$j = $i-3;
#		print $j, "\n";
		print @array[$j], "\n";
		print $fout @array[$j], "\n";
		print @array[$j+1], "\n";
		print $fout @array[$j+1], "\n";
		print @array[$j+2], "\n";
#		print $i, "\n";
		print @array[$i], "\n";
		print "\n";
#		print "copy: \n";
#		for($index = 0; $index < 2; $index++, $j++)
#		{
#			print @array[$j];
#		}
	}
	
}
print "\n";
close ($fout);

